#coding=utf-8
import socket
import sys
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host="www.jingsee.com"
port=80
try:
    ip=socket.gethostbyname(host)
    print "ip is ",host
except Exception as e:
    print "获取ip失败",e

if ip:
    s.connect((ip,port))
    try:
        #Set the whole string
        s.sendall("GET / HTTP/1.1\r\nHost: www.sina.com.cn\r\nConnection: close\r\n\r\n")
        print 'Message send successfully'
    except socket.error:
        #Send failed
        print 'Send failed'
        sys.exit()
else:
    sys.exit()

reply = s.recv(4096)

print reply
s.close()
